package org.alternativedev.wo42.gameobjects;

import org.alternativedev.wo42.Game;
import org.alternativedev.wo42.enums.MoveDirection;
import org.alternativedev.wo42.map.Map;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public abstract class Spell extends GameObject {
	private float posX, posY;
	private Animation spellLeft, spellRight, spellUp, spellDown;

	public Spell(Image[] gfxUp, Image[] gfxDown, Image[] gfxLeft,
			Image[] gfxRight, int[] dur) {
		spellUp = new Animation(gfxUp, dur, false);
		spellDown = new Animation(gfxDown, dur, false);
		spellLeft = new Animation(gfxLeft, dur, false);
		spellRight = new Animation(gfxRight, dur, false);

	}

	public void draw(Game game) {
		switch (game.map.getPlayer().getMovementDirection()) {
		case UP:
			spellUp.draw(posX, posY);
			break;
		case DOWN:
			spellDown.draw(posX, posY);
			break;
		case LEFT:
			spellLeft.draw(posX, posY);
			break;
		case RIGHT:
			spellRight.draw(posX, posY);
			break;

		}
	}

	/**
	 * Get the entities' position on the Y-Axis
	 * 
	 * @return The entities' position on the Y-Axis
	 */
	public float getPositionY() {
		return posY;
	}

	/**
	 * Set the entities' position on the Y-Axis
	 * 
	 * @param positionY
	 *            The new Position on the Y-Axis
	 */
	public void setPositionY(float positionY) {
		this.posY = positionY;
	}

	/**
	 * Get the entities' position on the X-Axis
	 * 
	 * @return The entities' position on the X-Axis
	 */
	public float getPositionX() {
		return posX;
	}

	/**
	 * Set the entities' position on the X-Axis
	 * 
	 * @param positionX
	 *            The new Position on the X-Axis
	 */
	public void setPositionX(float positionX) {
		this.posX = positionX;
	}

	@Override
	public int getWidth() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int getHeight() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void onUpdate(GameContainer gc, int delta, Map map, Game game)
			throws SlickException {
		if (game.map.getPlayer().getMovementDirection() == MoveDirection.UP) {
			posX = (int) game.map.getPlayer().getPositionX();
			posY = (int) game.map.getPlayer().getPositionY() - 1;
		}
		if (game.map.getPlayer().getMovementDirection() == MoveDirection.DOWN) {
			posX = (int) game.map.getPlayer().getPositionX();
			posY = (int) game.map.getPlayer().getPositionY() + 1;
		}
		if (game.map.getPlayer().getMovementDirection() == MoveDirection.LEFT) {
			posX = (int) game.map.getPlayer().getPositionX() - 1;
			posY = (int) game.map.getPlayer().getPositionY();
		}
		if (game.map.getPlayer().getMovementDirection() == MoveDirection.RIGHT) {
			posX = (int) game.map.getPlayer().getPositionX() + 1;
			posY = (int) game.map.getPlayer().getPositionY();
		}

	}
	
	public abstract int getManaNeeds();
}
